package com.lagou.edu.utils;

import java.sql.SQLException;
public class TransactionManager {
    private static  TransactionManager transactionManager = new TransactionManager();
    private TransactionManager (){}

    private  ConnnectioUtils connnectioUtils;

    public void setConnnectioUtils(ConnnectioUtils connnectioUtils) {
        this.connnectioUtils = connnectioUtils;
    }

    public void beginTransaction() throws SQLException {
        connnectioUtils.getCurrentConnection().setAutoCommit(false);
    }
    public void commit() throws SQLException {connnectioUtils.getCurrentConnection().commit();}
    public void rollback() throws SQLException {connnectioUtils.getCurrentConnection().rollback();}

    public static TransactionManager getTransactionManager(){
        return transactionManager;
    }
}
